using FreeSql.DataAnnotations;
using SumerCoreDevOps.Shared.Enums;

namespace SumerCoreDevOps.Domain.Entities;

/// <summary>
/// 工作流定义
/// </summary>
[Table(Name = "workflow_definitions")]
[Index("idx_name", nameof(Name), false)]
public class WorkflowDefinition
{
    [Column(IsPrimary = true, IsIdentity = true)]
    public long Id { get; set; }

    /// <summary>
    /// 工作流名称
    /// </summary>
    [Column(StringLength = 200)]
    public string Name { get; set; } = null!;

    /// <summary>
    /// 描述
    /// </summary>
    [Column(StringLength = 500)]
    public string? Description { get; set; }

    /// <summary>
    /// 版本号
    /// </summary>
    [Column(StringLength = 50)]
    public string Version { get; set; } = "1.0.0";

    /// <summary>
    /// 是否启用
    /// </summary>
    public bool IsEnabled { get; set; } = true;

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;

    /// <summary>
    /// 创建人
    /// </summary>
    [Column(StringLength = 100)]
    public string? CreatedBy { get; set; }

    /// <summary>
    /// 阶段列表
    /// </summary>
    [Navigate(nameof(Stage.WorkflowDefinitionId))]
    public List<Stage> Stages { get; set; } = [];
}
